import instance from "../../utils/request";



class Ax{
    constructor(contentType="application/json", token="") {
        this.contentType = {
            "Content-Type": contentType,
            "Authorization": "Bearer " + token
        }
    }

    getBasketLines(params={}){
        return instance({
            method:"get",
            url:"/basket/admin/baskets",
            header: this.contentType,
            query:params
        })
    }

    deleteBasketLines(basket_id="", lines="", token=""){
        return instance({
            method: "delete",
            url: "/basket/baskets/" + basket_id,
            data: {product_ids: String(lines)},
            headers: {"Authorization": "Bearer " + token}
        })
    }

    putBasketLines(basket_id="", lines="", chioch=true, token=""){
        return instance({
            method:"put",
            url:"/basket/baskets/" + basket_id,
            data:{product_id:lines, choice:chioch},
            headers: {"Authorization": "Bearer " + token}
        })

    }

    getUserAddress(pamas={}){
        return instance({
            method: "get",
            url: "/user/register/address-info",
            query: pamas,
            headers: this.contentType

        })
    }

    createBasket(token){
        return instance({
            method: "post",
            url:"/basket/baskets",
            headers:{"Authorization": "Bearer " + token}
        })
    }

    updataOrder(basket_id, token, data={}){
        return instance({
            method:"put",
            url: "/basket/baskets/" + basket_id,
            data:data,
            headers: {"Authorization": "Bearer " + token}
        })
    }

    addressCreate(token, data={}){
        return instance({
            method:"post",
            url: "/user/info/add-address",
            data:data,
            headers: {"Authorization": "Bearer " + token}
        })
    }

}


export default Ax